package com.example.sell.bean;

import com.example.sell.enums.EnumUtil;
import com.example.sell.enums.ProductStatus;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.math.BigDecimal;

/**
 * Created by IntelliJ IDEA.
 * 商品信息
 *
 * @author ouyangzhixiang
 * @date 2018/6/28
 */
@Entity
@Data
public class ProductInfo {
    @Id
    private String productId;
    /**
     * 商品名字
     */
    private String productName;
    /**
     * 商品价格
     */
    private BigDecimal productPrice;
    /**
     * 商品库存
     */
    private Integer productStock;
    /**
     * 商品描述
     */
    private String productDescription;
    /**
     * 商品小图
     */
    private String productIcon;
    /**
     * 商品上下架状态，0正常1下架
     */
    private Integer productStatus;
    /**
     * 商品类目编号
     */
    private Integer categoryType;

    @JsonIgnore
    public ProductStatus getProductStatusEnum(){
        return EnumUtil.getByCode(productStatus,ProductStatus.class);
    }

}
